package com.cn.ycy.service;

import com.alibaba.fastjson.JSONObject;
import com.jayway.jsonpath.JsonPath;

/**
 * 接口请求模版
 */
public class RequestTemplete {

  public String requesturl;
  public String requestmethod;
  //token路径
  public String responsebodyTokenath;
  //token默认值
  public String responsebodyDefaultToken;
  //token生命周期路径
  public String responsebodyExpiretimePath;
  //token默认生命周期
  public int responsebodyDefaultxpiretime;


  public static void main(String[] args) {
    RequestTemplete requestTemplete = new RequestTemplete();
    requestTemplete.requesturl = "localhost:9991";
    requestTemplete.requestmethod = "get";
    requestTemplete.responsebodyTokenath = "data.accessToken";
    requestTemplete.responsebodyDefaultToken = "asdfg";
    requestTemplete.responsebodyExpiretimePath = "data.expireTime";
    requestTemplete.responsebodyDefaultxpiretime = 1000;
    String json = JSONObject.toJSONString(requestTemplete);
    System.out.println(json);

    try {
      int val = JsonPath.read(json, "$." + "responsebodyDefaultxpiretime");
      System.out.println(val);
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }
  }

}
